package Messages;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * This class implements the flower inventory from the DB 
 * @author Gabi Revah
 * @author Aviad Almog
 */ 
public class MessageFlowerInv {
	
	private ConnectionToClient client ;
	private String[] str; 
/**
 * Constructor of this class 
 * @param str
 * @param client
 */
	public MessageFlowerInv(String[] str, ConnectionToClient client) {
		this.client= client ;
		this.str= str; 
	
	}
	/**
	 * This method gets all the flower inventory from the DB  
	 * @throws SQLException
	 * @throws IOException
	 */
	public void FlowerInv() throws SQLException, IOException{
		
		
		SQLConnection sc = new SQLConnection();
		
		java.sql.PreparedStatement ps = sc.getConnection().prepareStatement("SELECT * FROM db.flowers");
		ResultSet FlowerInvRes= ps.executeQuery();
		ArrayList<Object> fi=new ArrayList<Object>();
		fi.add("FlowerInv");
		while (FlowerInvRes.next())
		{
			fi.add(FlowerInvRes.getString(1));
			fi.add(FlowerInvRes.getString(2));
			fi.add(FlowerInvRes.getInt(3));
			fi.add(FlowerInvRes.getInt(4));
			fi.add(FlowerInvRes.getInt(5));
			fi.add(FlowerInvRes.getInt(6));
		}
		client.sendToClient(fi);
	}
}


